<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
<%@ include file="/common/plateform/include/common-base.jsp"%>	
  <script src="${ctx}/js/uct/date.js"></script>
  <title>审计日志查询</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">
  <!-- top start -->
  <%@include file="/common/plateform/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/plateform/left.jsp" %>
  <!-- left end-->
  <div class="content-wrapper">
    <!-- Main start -->
<section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <!-- /.box-header -->
            <div class="box-body">
            <center>
				<form id="searchFrom" class="form-horizontal">
				<input type="hidden" name="doCode" value="logOperationList"/>
				<table class="table table-bordered table-hover" border="0">
				<tr>
				    <td>系统名称</td>
				    <td><input type="text" class="form-control" name="modelSysname"  id="modelSysname" /></td>
				    <td>业务名称</td>
				    <td><input type="text" class="form-control" name="modelBussiness"  id="modelBussiness" /></td>
				    <td>操作对象</td>
				    <td><input type="text" class="form-control" name="modelCname"  id="modelCname" /></td>
				    <td align="center" rowspan="2" >
						<button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-edit-circle"></i> 查询</button> 
					</td>
				    </tr>
				    <tr>
				    <td>操作类型</td>
				    <td><input type="text" class="form-control" name="logType"  id="logType" /></td>
				    <td>操作时间</td>
				    <td><input type="text" class="form-control" name="createdTime"  id="createdTime" class="easyui-datebox" /></td>
					<td>操作人账号</td>
				    <td><input type="text" class="form-control" name="createUser"  id="createUser" /></td>
				</tr>
			</table>
				</form>
				</center>
            
              <table id="example" class="table table-bordered table-hover" >
                <thead>
                <tr>
                  <th>系统名称</th>
                  <th>业务名称</th>
                  <th>操作对象</th>
                  <th>操作类型</th>
                  <th>操作时间</th>
                  <th>操作人账号</th>
                  <th>操作IP或域名</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody id="myList">
                </tbody>
              </table>
         	    <center>
    	  			  <ul id="pageList"></ul>
        		</center>
            </div>
          </div>
        </div>
      </div>
    </section>
    
    <div class="modal fade" id="my_modal_detail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" title="查看审计日志详细">
	<div class="modal-dialog" style="width:1000px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					</div>
					<div class="modal-body">
					 <center id="itemInfo_center"></center>
						<table id="example_detail" class="table table-bordered table-hover" >
		                <thead>
		                <tr>
		                  <th>属性</th>
		                  <th>属性名称</th>
		                  <%--<th>旧值</th>--%>
		                  <th>新值</th>
		                </tr>
		                </thead>
		                <tbody id="detailList">
		                </tbody>
		              </table>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  
    
    <!-- Main end -->
    	<script type="text/template" id="dataList">
	  		<? for ( var i = 0; i < rows.length; i++) {?>
				<tr>
					<td style="display:none;"><?=rows[i].logId?></td>
					<td><?=rows[i].modelSysname?></td>
					<td><?=rows[i].modelBussiness?></td>
					<td><?=rows[i].modelCname?></td>
					<td><?=rows[i].logType?></td>
					<td><?=getSmpFormatDateByLong(rows[i].createdTime,true)?></td>
					<td><?=rows[i].createUser?></td>
					<td><?=rows[i].logIp?></td>
					<td><a href="javascript:void(0)" onclick="view('<?=rows[i].logId?>')">查看详细</a></td>
				</tr>
     		<?}?>
	</script>

<script type="text/template" id="detail_List">
	  		<? for ( var i = 0; i < rows.length; i++) {?>
				<tr>
					<td><?=rows[i].propertyEname?></td>
					<td><?=rows[i].propertyName?></td>
					<td><?=rows[i].propertyValue?></td>
				</tr>
     		<?}?>
	</script>
<script type="text/template" id="itemInfo">
查看审计日志详细内容&nbsp;&nbsp; 业务名称:<?=ddd.modelBussiness?>&nbsp;&nbsp; <font color=red><?=ddd.logType?></font>
</script>	
<script>
var clickMenu= 'log-operation-list';
var id;
$(function () {
	getTableData();
	$('#example tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	            //$(this).removeClass('selected');
	        }
	        else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     id = $('tr.selected td').eq(0).html();
	   //  console.log($('tr.selected td').eq(1).html())
	} );
  });
  
//设置模态框隐藏事件钩子  
$( '#my_modal' ).on( 'hide.bs.modal' ,function(e){  
	cleanData('userFormData');
}); 

//设置模态框隐藏事件钩子  
$( '#my_modal' ).on( 'show.bs.modal' ,function(e){  
	$.ajax({
	    type:'get',
	    url:'${ctx}/sendPage/token?token=true',
	    dataType:'json',
	    success: function(myData){
	    	//console.log(myData);
			 $('#formToken').val(myData);
	  	}
	});	
}); 

function cleanData(id){
	$(':input','#'+id)  
	 .not(':button, :submit, :reset, :hidden')  
	 .val('')  
	 //.removeAttr('checked')  
	 .removeAttr('selected'); 
}

function getTableData(){
	deleteAllRow('example');
	var utrlss="${ctx}/trans/list/";
	$.ajax({
		   type:'post',
		   url:utrlss,//user_search_url,
		   data:$('#searchFrom').serialize()+getCurrentPage(utrlss+"?"+$('#searchFrom').serialize(),15),
		   dataType:'json',
		   success: function(myData){
			var data = baidu.template('dataList',eval(myData));  
			$("#myList").html(data);
			  var option= {
					   ele:$("#pageList")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:user_search_url+"?"+$('#searchFrom').serialize()
				   }
			generatePages(option);
		   }
		});	
  }

function deleteAllRow(tableId){
	var tb = document.getElementById(tableId);
	if(tb){
	     var rowNum=tb.rows.length;
	     for (var i=1;i<rowNum;i++){
	         tb.deleteRow(i);
	         rowNum=rowNum-1;
	         i=i-1;
	     }
     }
}

function view(logId){
	//window.location="${page_admin}/audit/log-operation-view?logId="+logId;
	$('#my_modal_detail').modal('show');
	deleteAllRow('example_detail');
	var utrlss="${ctx}/trans/info/?doCode=viewLogDetail&logId="+logId;
	$.ajax({
		   type:'get',
		   url:utrlss,//user_search_url,
		   data:$('#searchFrom').serialize(),
		   dataType:'json',
		   success: function(myData){
			   console.log(myData);
			var test ={};
			test.ddd=myData.item;
			var data2 = baidu.template('itemInfo',test);  
			$("#itemInfo_center").html(data2);
			var data = baidu.template('detail_List',myData);  
			console.log(myData);
			$("#detailList").html(data);
		   }
	});	
}

function cannel(modalId){
	$('#'+modalId).modal('hide');
}

function refresh(){
    //window.location.reload();
	getTableData();
}
</script>




  </div>
  <!-- /.content-wrapper -->
  
  <!-- foot start -->
       
 <%@include file="/common/plateform/foot.jsp" %>
</div>    

</body>

</html>
